package com.nageoffer.shortlink.admin.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * ClassName: DataBaseConfiguration
 * Package:
 * Description:
 *
 * @Author:xiaohei
 * @Create 2024/6/6 12:16
 * Version 1.0
 */

@Configuration(value = "dataBaseConfigurationByAdmin")
public class DataBaseConfiguration {
    /**
     * 分页插件
     */
    @Bean
    @ConditionalOnMissingBean  //在生成此bean的时候去IOC容器里检查是否含有此Bean  如果有则此Bean不生效
    public MybatisPlusInterceptor mybatisPlusInterceptorByAdmin(){
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor(DbType.MYSQL));
        return interceptor;
    }
}
